package com.example.controller;

import com.example.entity.Result;
import com.example.utils.WarehouseConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:tjf
 * @Description:登出控制器类
 */
@RestController
public class LogoutController {
    /**
     * 用户登出接口url/logout
     * @return
     */
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @RequestMapping("/logout")
    public Result logout(@RequestHeader(WarehouseConstants.HEADER_TOKEN_NAME) String token){
        // 从redis缓存中移除令牌token
        stringRedisTemplate.delete(token);
        return Result.ok();
    }
}
